#!/bin/bash
(
cat << EOF
firewall --disabled
install
url --url="http://$1/os/$2/$3"
rootpw --plaintext $4
auth  --useshadow  --passalgo=sha512
#graphical
text
keyboard us
lang en_US.UTF-8
selinux --disabled
skipx
logging --level=info
reboot
timezone --utc Asia/Shanghai
network  --bootproto=dhcp --device=eth0 --onboot=on
bootloader --location=mbr
zerombr
clearpart --all --initlabel
#part / --fstype="ext4" --grow --ondisk=sda --size=1
#part /tmp --fstype="ext4" --ondisk=sda --size=20480
#part swap --fstype="swap" --size=500

part /boot/efi --fstype="efi" --ondisk=sda --size=300
EOF
) > $5
partlist=""
grep -v "^#" conf/partitions.conf | while read lines
do
if [ `echo $lines | awk '{print $3}'` = 1  ];then
partlist="part `echo $lines | awk '{print $1}'` --fstype=\"`echo $lines | awk '{print $2}'`\" --grow --ondisk=sda --size=`echo $lines | awk '{print $3}'`"
else
partlist="part `echo $lines | awk '{print $1}'` --fstype=\"`echo $lines | awk '{print $2}'`\" --ondisk=sda --size=`echo $lines | awk '{print $3}'`"
fi
echo $partlist >> $5
done
(
cat << EOF

%packages --ignoremissing
@base
@core
@fonts
@debugging
@development
gcc
make
tree
nmap
sysstat
telnet
python
%end

#%addon com_redhat_kdump --disable --reserve-mb='auto'
#%end

%post
sed -i "/UseDNS/d" /etc/ssh/sshd_config
echo 'UseDNS no' >> /etc/ssh/sshd_config
echo 0> /etc/resolv.conf
service iptables stop
chkconfig iptables off
%end
EOF
) >> $5

echo -e "ks.cfg is create \033[32mSuccessful\033[0m"

